package com.wyutil.wy_FileFormatConversion.ImageWithExcel;

import org.apache.poi.ss.usermodel.Drawing;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

//TODO:https://blog.csdn.net/qq_16599211/article/details/136727410?ops_request_misc=&request_id=&biz_id=102&utm_term=java%20%E4%BB%A3%E7%A0%81%20excel%E8%BD%AC%E5%9B%BE%E7%89%87%20&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-2-136727410.142^v100^control&spm=1018.2226.3001.4187
public class ExcelToImage2 {
    public static void main(String[] args) throws IOException {
        String excelPath = "";
        Workbook sheets = WorkbookFactory.create(new File(excelPath));
        Sheet sheetAt = sheets.getSheetAt(0);
        BufferedImage bufferedImage = new BufferedImage(sheetAt.getPhysicalNumberOfRows() * 30, sheetAt.getLastRowNum() * 20, BufferedImage.TYPE_INT_RGB);
        Graphics2D graphics = bufferedImage.createGraphics();
        Drawing drawing= sheetAt.createDrawingPatriarch();
        File outPath = new File("outPath");
        ImageIO.write(bufferedImage,"png",outPath);

    }
}
